package _4_decorator

//抽象构件
type Component interface {
	Calc() int
}

//具体构件
type ConcreteComponent struct {

}

func (self *ConcreteComponent) Calc() int{
	return 66
}

//抽象装饰
type Decorator struct {
	Component
	num int
}
//具体装饰
type MulDecorator struct {
	*Decorator
}

func (self *MulDecorator) Calc()int  {
	return self.Component.Calc() * self.num
}

func NewMulDecorator(c Component,num int ) Component{
	return &MulDecorator{
		&Decorator{
			c,
			num,
		},
	}
}

//具体装饰
type AddDecorator struct {
	Component
	num int
}

func (self *AddDecorator) Calc()int  {
	return self.Component.Calc() + self.num
}

func NewAddDecorator(c Component, num int)Component{
	return &AddDecorator{
		c,
		num,
	}
}
